<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['member']=cfc('core')->get_member($_SESSION['uid']);
	$sharelink='jy_merch/game//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>$return['basic']['title']?$return['basic']['title']:'活动页-商户活动',
			'desc'=>$return['basic']['desc']?$return['basic']['desc']:'商户活动，一个属于商户活动！',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>ATTACHMENT_URL.$return['basic']['logo']
	);
	$return['setting']['bankuai2']=$return['basic']['bankuai2'];
	$return['list']=array();
	$return['pcd']=array();
	$return['params']['type']='jy_bargain';
	set_html('title',$return['basic']['title']?$return['basic']['title']:'商户活动');
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'merchid >'=>0
	);
	$type=$_RQ['type'];
	if($type=='jy_bigwheel'){
		$params['plugin_name']='jy_bigwheel';
		$geturl='jy_weishop_game';
	}elseif($type=='jy_bargain'){
		$geturl='jy_bargain_goods';
	}elseif($type=='jy_pingdd_pin'){
		$geturl='jy_pingdd_pin_goods';
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['list']=pdo_getslice($geturl,$params,array($pindex,$psize),$total,array(),'','id desc');
	foreach($return['list'] as $k=>&$item){
		if($type=='jy_pingdd_pin'){
			$goods=pdo_get('jy_weishop_goods',array('id'=>$item['goodsid']),array('title','image','marketprice','price'));
			$goods['oldprice']=$goods['price'];
			$item=array_merge($goods,$item);
			$item['url']='jy_pingdd_pin/goods.detail//id='.$item['goodsid'];
		}
		if($type=='jy_bigwheel'){
			$item['url']='jy_bigwheel/game//id='.$item['id'];
		}
		if($type=='jy_bargain'){
			$goods=pdo_get('jy_weishop_goods',array('id'=>$item['goods_id']),array('title','image','marketprice','price'));
			$item=array_merge($goods,$item);
			$item['url']='jy_bargain/detail//id='.$item['id'];
		}
	}
	exi($return);
}
?>